﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutomatedAcceptanceTests.PageObjects;
using AutomatedAcceptanceTests.Test;
using AutomatedAcceptanceTests.WorkFlows;
using NUnit.Framework;
using TechTalk.SpecFlow;

namespace AutomatedAcceptanceTests.StepDefinitions
{
    [Binding]
    public class Login 
    {
        // Init those objects at some porper place
        LoginPageObject _loginPageObject = new LoginPageObject();
        HomePagePageObject  _homePagePageObject = new HomePagePageObject();
        UserAccountWorkFlow _userAccountWorkFlow = new UserAccountWorkFlow();
        
        [Given(@"I am not logged in user")]
        public void GivenIAmNotLoggedInUser()
        {
            // For readability
        }
        
        // add login url in config file.

        [Given(@"I navigate to login page")]
        public void GivenINavigateToLoginPage()
        {
            //ScenarioContext.Current.Pending();
            // refactor this
            _loginPageObject.GoToUrl(_loginPageObject.BaseUrl);
        }

        [Given(@"I enter username '(.*)' and password '(.*)'")]
        public void GivenIEnterUsernameAndPassword(string userName, string password)
        {
            _loginPageObject.EnterUserName(userName);
            _loginPageObject.EnterPassword(password);
        }

        [When(@"I click login button")]
        public void WhenIClickLoginButton()
        {
            _loginPageObject.ClickSubmit();
        }

        [Then(@"I am successfully logged into the system")]
        public void ThenIAmSuccessfullyLoggedIntoTheSystem()
        {
            Assert.True(_homePagePageObject.AmIOnHomePage());
        }

        [Given(@"I am already login to the system with username '(.*)' and password '(.*)'")]
        public void GivenIAmAlreadyLoginToTheSystemWithUsernameAndPassword(string userName, string password)
        {
            _loginPageObject.LoginUser(userName, password);
        }

    }
}
